package com.neutech.Demo1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class BaseDao {
    private static Connection conn;
    //加载数据库驱动
    public static final String DRIVER ="com.mysql.cj.jdbc.Driver";
    //获取连接
    public static final String URL="jdbc:mysql://localhost:3306/test";
    public static final String USER="root";
    public static final String PASSWORD="root";

    //利用静态代码块来实现创建sql连接
    static {
        try {
            Class.forName(DRIVER);
            conn = DriverManager.getConnection(URL,USER,PASSWORD);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public BaseDao(){

    }
    public static Connection getConn(){
        return conn;
    }

    public static void close(Statement st){
    }
    public static void close(ResultSet rs,Statement st){

    }
    public static void close(){}
}
